﻿using System.Diagnostics.Contracts;

namespace TaskManager.Domain.BusinessObjects
{
    /// <summary>
    /// Project log entry
    /// </summary>
    public class ProjectLogEntry : LogEntry
    {
        /// <summary>
        /// Project identifier
        /// </summary>
        public int ProjectId { get; private set; }

        /// <summary>
        /// Reference to a project
        /// </summary>
        /// <remarks>Lazy-loaded property</remarks>
        public virtual Project Project { get; private set; }

        /// <summary>
        /// Parameterless constructor
        /// </summary>
        public ProjectLogEntry()
        {
            
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="user">User who modified project</param>
        /// <param name="message">Message</param>
        public ProjectLogEntry(Project project, User user, string message)
            :base(user, message)
        {
            Contract.Requires(project != null);

            User = user.Name;
            Message = message;

            project.Logs.Add(this);
        }
    }
}